//
//  ViewController.m
//  字符串创建
//
//  Created by clz on 2019/7/14.
//  Copyright © 2019年 clz. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property(nonatomic,strong)NSString *name;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    self.name = @"111ffff";
//    NSString *str = @"aaa";
//    NSString *str1 = [[NSString alloc]init];
    
//    NSString *str = @"";
    //str
    //name
//    {
//        @"name":@"xiaoming",
//        @"age":@"17"
//    }
    
    //字符的操作
    //截取
    //重头开始截取
    NSString *str = @"HeadCenterEndCCC";
    NSString *tempStr = [str substringToIndex:4];
//    NSLog(@"tempStr = %@",tempStr);
    
    //截取尾部
    NSString *tempStr1 = [str substringFromIndex:str.length - 3];
//    NSLog(@"tempStr1 = %@",tempStr1);
    
    //截取中间的一个区域的字符
    NSRange range;
    range.location = 4;
    range.length = 6;
    NSString *temStr2 = [str substringWithRange:range];
//    NSLog(@"temStr2 = %@",temStr2);
    
    //替换字符串中的字符
    NSString *tempStr3 = [str stringByReplacingOccurrencesOfString:@"C" withString:@"A"];
//    NSLog(@"tempStr3 = %@",tempStr3);
    
    //替换某一段字符
    NSRange range1 = NSMakeRange(4, 6);
    NSString *tempStr4 = [str stringByReplacingCharactersInRange:range1 withString:@"Middle"];
//    NSLog(@"111");
    
    //分割字符串
    NSString *str1 = @"111,222,333,444";
    NSArray *tempArray = [str1 componentsSeparatedByString:@","];
//    NSLog(@"tempArray = %@",tempArray);
    
    NSString *str2 = @"name:xiaoming;age:11;height:170";
    NSArray *tempArray2 = [str2 componentsSeparatedByString:@";"];
//    NSLog(@"tempArray2 = %@",tempArray2);
    
    //字符串的拼接
    NSString *str3 = @"1111";
    NSString *str4 = @"2222";
    NSString *tempStr5 = [NSString stringWithFormat:@"%@-%@",str3,str4];
    NSLog(@"tempStr5 = %@",tempStr5);
    
    NSString *phoneNUmber = @"123456";
    //手机号码：？
    NSString *resultStr = [NSString stringWithFormat:@"手机号码：%@",phoneNUmber];
    NSLog(@"resultStr = %@",resultStr);
    
    
    int a = 5;
    NSString *tempStr6 = [NSString stringWithFormat:@"%@%d",str3,a];
//    NSLog(@"tempStr6 = %@",tempStr6);
    
    
}


@end
